# -*- coding: utf-8 -*-
"""
    author: Ye
    date: 2021/01/25 11:17
"""
from datetime import datetime,date
from extensions import db


class Author(db.Model):
    __tablename__ = 'author'
    id = db.Column(db.Integer,primary_key=True)
    name = db.Column(db.String(100),nullable=False,comment='姓名')
    create_time = db.Column(db.DateTime,default=datetime.now)
    books = db.relationship('Book',backref='author')


class Book(db.Model):
    __tablename__ = 'book'
    id = db.Column(db.Integer,primary_key=True)
    name = db.Column(db.String(50),nullable=False,comment='书名')
    create_time = db.Column(db.DateTime,default=datetime.now)
    author_id = db.Column(db.Integer,db.ForeignKey('author.id'),nullable=False)